package com.ruoyi;

import java.net.InetAddress;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import com.ruoyi.biz.service.diskfile.IFileItemStoreService;

/**
 * 启动程序
 * 
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication implements CommandLineRunner {
	
	@Autowired
	IFileItemStoreService storeItemService;
	
	public static void main(String[] args) throws Exception {
		// System.setProperty("spring.devtools.restart.enabled", "false");
		// SpringApplication.run(RuoYiApplication.class, args);
		ConfigurableApplicationContext application = SpringApplication.run(RuoYiApplication.class, args);
		//
		Environment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String contextPath = env.getProperty("server.servlet.context-path");
		if (contextPath == null) {
			contextPath = "";
		}
		System.out.println("\n----------------------------------------------------------\n\t"
				+ "Application is running! Access URLs:\n\t" + "Local: \t\thttp://localhost:" + port + contextPath
				+ "\n\t" + "External: \thttp://" + ip + ':' + port + contextPath + '\n'
				+ "----------------------------------------------------------");
	}
	
	@Override
	public void run(String... arg) throws Exception {
		storeItemService.init();
	}

}